#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    int sum=0;
    char c;
    while(c=getchar())
    {
        if(c=='\n')
        {
            cout<<sum<<endl;
            c=getchar();
            if(c=='0') break;
            else sum =c-'0';

            continue;
        }
        sum +=c-'0';
        if(sum>9) sum = sum/10+sum%10;
    }
    return 0;
}
